<?php defined('SYSPATH') or die('No direct script access.');

class string {

    /**
     * Used when suggesting a login for a person.
     */
    public static function toLowerCaseAsciiText($text) {
        return strtolower(iconv("UTF-8","ASCII//TRANSLIT", $text));
    }

    public static function longTextShort($text, $maxLength=48) {
        if (strLen($text) > $maxLength) {
            $spaceIndex = strpos($text, ' ', max($maxLength - 3, 0));
            $text = substr($text, 0, $spaceIndex) . ' ...';
        }
        return $text;
    }

    public static function fileNameReady($name) {
        $forbiddenChars = array('/', '\\', ':', '*', '?', '"', '>', '<', '|');
        return str_replace($forbiddenChars, "", $name);
    }
}
